<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
	<title>Update the Group-Buying Meeting</title>

	<link rel="stylesheet" type="text/css" href="${ctx}/styles/sidecss.css"/>
	<link rel="stylesheet" type="text/css" href="${ctx}/styles/uploadify/uploadify.css" />
	<link rel="stylesheet" type="text/css" href="${ctx}/scripts/select2/css/select2.css">

	<script type="text/javascript" src="${ctx}/scripts/WinSollAuto.js"></script>
	<script type="text/javascript" src="${ctx}/widgets/My97DatePicker/WdatePicker.js"></script>
	<script type="text/javascript" src="${ctx}/scripts/uploadify/swfobject.js"></script>
	<script type="text/javascript" src="${ctx}/scripts/highchart/jquery-1.8.2.min.js"></script>
	<script type="text/javascript" src="${ctx}/scripts/uploadify/jquery.uploadify-3.1.min.js"></script>
	<script type="text/javascript" src="${ctx}/scripts/base.js"></script>
	<script type="text/javascript" src="${ctx}/scripts/select2/js/select2.min.js"></script>
	<script type="text/javascript" src="${ctx}/wrigley/js/jquery.form.js"></script>

	<link rel="stylesheet" href="${ctx}/widgets/jquery/ui/css/jquery-ui.min.css" />
	<script type="text/javascript" src="${ctx}/widgets/jquery/ui/js/jquery-ui.min.js"></script>
	<script type="text/javascript" src="${ctx}/scripts/zDialog.js"></script>
	<style>
		.opa{width:100%; height:100%; position:fixed; top:0; left:0; display: none; background: rgba(0,0,0,0.6); z-index:9999999;}
		.opa.on{ display: block; }
		.img{width:100%; height:100%; position:fixed; top:0; left:0; display: none;}
		.img.on{ display: block; }
		#dicount tr td input {padding-right: 0px;}
	</style>
	<script type="text/javascript">
		var errMsg = "";
        function discountCompare(obj) {
            for(var i = 0; i < $(".discountPrice").length; i++){
                if(i > 0 && parseFloat($(".discountPrice").eq(i).val()) <= parseFloat($(".discountPrice").eq(i - 1).val())){
                    $(".discountPrice").eq(i).next().html("The total reduction amount is not as large as the previous level [does not affect the preservation]");
				} else if(i > 0 && parseFloat($(".discountPrice").eq(i).val()) > parseFloat($(".discountPrice").eq(i - 1).val())) {
                    $(".discountPrice").eq(i).next().html("");
				}
			}
        }
        /* function winSalerCompare(obj) {
            for(var i = 0; i < $(".winSalerPrice").length; i++){
                if(i > 0 && parseFloat($(".winSalerPrice").eq(i).val()) <= parseFloat($(".winSalerPrice").eq(i - 1).val())){
                    $(".winSalerPrice").eq(i).next().html("The discount amount of the order is not as big as the previous level [does not affect the preservation]");
                } else if(i > 0 && parseFloat($(".winSalerPrice").eq(i).val()) > parseFloat($(".winSalerPrice").eq(i - 1).val())) {
                    $(".winSalerPrice").eq(i).next().html("");
                }
            }
        } */
        
    	// 通过 Proportion of Fees Borne by Hui Order 计算 惠下单承担费用，
        // 公式: 订单金额满xx元 * 惠下单承担费比（%）=惠下单承担费用
        function winSalerCount(obj) {
        	var len = 2; // 小数点后位数
        	var winSalerRatio = $(obj).parents("tr").find(".winSalerRatio");
        	var activityPrice = $(obj).parents("tr").find(".activityPrice");
        	var winSalerPrice = $(obj).parents("tr").find(".winSalerPrice");
        	var prevWinSalerPrice = $(obj).parents("tr").prev().find(".winSalerPrice");
        	
        	if (winSalerRatio.val() == "") {
        		winSalerRatio.val(0);
            }
        	var ratio = parseFloat(winSalerRatio.val());

            if (ratio > 100) {
            	winSalerRatio.val(100);
            } else if (ratio < 0) {
            	winSalerRatio.val(0);
            } else {
                if (len == 0) {
                    if (winSalerRatio.val().indexOf('.') > -1) {
                    	winSalerRatio.val(winSalerRatio.val().substring(0, winSalerRatio.val().length - 1));
                    	winSalerRatio.focus();
                    }
                }
                if (winSalerRatio.val().indexOf('.') > -1) {
                    if (winSalerRatio.val().split('.')[1].length > len) {
                    	winSalerRatio.val(winSalerRatio.val().substring(0, winSalerRatio.val().length - 1))
                    	winSalerRatio.focus();
                    }
                }
            }
            
            ratio = parseFloat(winSalerRatio.val());
        	
        	winSalerPrice.val((parseFloat(activityPrice.val()) * (ratio / 100)).toFixed(len))
        	if (parseFloat(winSalerPrice.val()) <= parseFloat(prevWinSalerPrice.val())) {
        		winSalerPrice.next().html("The discount amount of the order is not as big as the previous level [does not affect the preservation]");
        	} else {
        		winSalerPrice.next().html("");
        	}
        	
        }
        
        $(document).ready(function(){
            var hdhRate = $("#hdhRate").val();
            if(hdhRate != null && hdhRate != ""){
                $("#hdhRate").val(hdhRate.substring(0, hdhRate.indexOf(".") + 3))
            }
            var hdhRebatePercent = $("#hdhRebatePercent").val();
            if(hdhRebatePercent != null && hdhRebatePercent != ""){
                $("#hdhRebatePercent").val(hdhRebatePercent.substring(0, hdhRebatePercent.indexOf(".") + 3))
            }
            var callBackProfits = $("#callBackProfits").val();
            if(callBackProfits != null && callBackProfits != ""){
                $("#callBackProfits").val(callBackProfits.substring(0, callBackProfits.indexOf(".") + 3))
            }
            //文本框失焦事件
            $("#name").blur(function () {
                var name = $("#name").val();
                var label = $(this).next();
                if(name.length <=0 || name.length > 20) {
                    label.html("Activity Name Length of 1-20！");
                    errMsg = "Activity Name Length of 1-20！";
                    return;
                } else {
                    label.html("");
                    errMsg = "";
                }
            })
            $("#startTime").blur(function () {
                var startTime = $("#startTime").val();
                if(startTime == "") {
                    var label = $(this).next();
                    label.html("The start time cannot be empty");
                    return;
                } else {
                    var label = $(this).next();
                    label.html("");
                }
            });
            $("#endTime").blur(function () {
                var endTime = $("#endTime").val();
                if(endTime == "") {
                    var label = $(this).next();
                    label.html("The end time cannot be empty");
                    return;
                } else {
                    var label = $(this).next();
                    label.html("");
                }
            })
            $("#dealerName").blur(function () {
                var dealerName = $("#dealerName").val();
                var label = $(this).next();
                if(dealerName == null || dealerName == "") {
                    label.html("Please select Distributor Name");
                    errMsg = "Please select Distributor Name";
                    return;
                } else {
                    label.html("");
                    errMsg = "";
                }
            })

            //保存
            $("#save").click(function(){
                var name = $("#name").val();
                if(name.length <=0 || name.length > 20) {
                    alert("Activity Name Length of 1-20！");
                    return;
                }
                var id = $("#id").val();
                checkActivityName(id, name);
                if(errMsg != ""){
                    alert(errMsg);
                    return;
                }

                if($("#startTime").val() == "") {
                    alert("The start time cannot be empty！");
                    return;
                }
                if($("#endTime").val() == "") {
                    alert("The end time cannot be empty！");
                    return;
                }
                var dealerName = $("#dealerName").val();
                if(dealerName == null || dealerName == "") {
                    alert("Please select Distributor Name");
                    return;
                }
                var areaName = $("#areaName").val();
                var newActivity = $("#newActivity").val();
                if(newActivity == "1" && areaName == "") {
                    alert("Please select Sales Area Name");
                    return;
                }
                var activityType = $("#activityType").val();
                if(activityType == null || activityType == "") {
                    alert("Please select Group-Buying Meeting Type");
                    return;
                }
                var itemName = $("#itemName").val();
                if(itemName == null || itemName == "") {
                    alert("Please select the activity category");
                    return;
                }
                var hdhRate = $("#hdhRate").val().trim();
                if(hdhRate == null || hdhRate == "") {
                    alert("Please enter the rate");
                    return;
                }
               // var r = /^\d+$/;
              //var r=/^(?!0+(?:\.0+)?$)(?:[1-9]\d*|0)(?:\.\d{1,2})?$/; 不包含0
            	var r=/^0{1}([.]\d{1,2})?$|^[1-9]\d*([.]{1}[0-9]{1,2})?$/; //包含0
                if(!r.test(hdhRate)){
                	alert("Incorrect rate input");
                    return;
                }
                var callBackProfits = $("#callBackProfits").val().trim();
                if(callBackProfits != "" && !r.test(callBackProfits)){
                    alert("Incorrect rebate input");
                    return;
				}
                var activeStoreQty = $("#activeStoreQty").val();
                var activeStoreQtyReg =/^[0-9]*$/; //包含0
                if(activeStoreQty != "" && !activeStoreQtyReg.test(activeStoreQty)){
                	alert("The total activity store input format is incorrect！");
                    return;
                }
                var GVM = $("#GVM").val();
                if(GVM != "" && !new RegExp("^[0-9]{1,}$").test(GVM) && !new RegExp("^[0-9]{1,}[.]{1}[0-9]{0,2}$").test(GVM)){
                    alert("GMV should retain two valid decimals");
                    return;
                }
                var storeNum = 0;
                $("input[name='storeActiveNums']").each(function (i) {
                    var storeActiveNum = $("input[name='storeActiveNums']").eq(i).val();
                    if(storeActiveNum != "" && storeActiveNum != null) {
                        if (isNaN(storeActiveNum)) {
                            alert("The number of active stores for the brand must be a number！");
                            storeNum = 1;
                            return false;
                        }
                        if (!((/^(\+|-)?\d+$/.test(storeActiveNum)) && storeActiveNum > 0)) {
                            alert("The number of brand active stores must be a positive integer greater than 0！");
                            storeNum = 1;
                            return false;
                        }
                    }
                });
                if(storeNum == 1){
                    return;
				}
                var bannerImg = $("#bannerImg").val();
                if(bannerImg == null || bannerImg == "") {
                    alert("Please upload pictures of the event details！");
                    return;
                }
                var hdhActivityProductList = new Array();
                var hdhDiscountInfoList = new Array();
                var hdhPayInfoList = new Array();
                if($("#prodId").val() == "" && ($("#excelFile").val() == "" || $("#excelFile").val() == null)){
                    alert("Please select product information");
                    return;
                }
                for(var i = 0; i < $(".salerPayWay").length; i++){
                    var hdhPayInfo = {};
                    var salerPayCode = parseInt($(".salerPayWay").eq(i).val());
                    if(salerPayCode == 14){
                        hdhPayInfo.payName = "支付宝支付";
                    } else if(salerPayCode == 10){
                        hdhPayInfo.payName = "快捷支付";
                    } else if(salerPayCode == 16){
                        hdhPayInfo.payName = "线下转账";
                    }else if(salerPayCode == 31){
                        hdhPayInfo.payName = "惠钱包支付";
                    }else if(salerPayCode == 32){
                        hdhPayInfo.payName = "惠钱包支付";
                    }
                    hdhPayInfo.payCode = salerPayCode;
                    hdhPayInfo.payTypeSign = '0'; //Payment Method of the Customer标识
                    hdhPayInfoList[i] = hdhPayInfo;
                }
                var len = hdhPayInfoList.length;
                for(var i = 0; i < $(".dealerPayWay").length; i++){
                    var hdhPayInfo = {};
                    var dealerPayCode = parseInt($(".dealerPayWay").eq(i).val());
                    if(dealerPayCode == 13){
                        hdhPayInfo.payName = "支付宝扫码";
                    } else if(dealerPayCode == 11){
                        hdhPayInfo.payName = "微信扫码";
                    } else if(dealerPayCode == 12){
                        hdhPayInfo.payName = "POS机刷卡";
                    }else if(dealerPayCode == 31){
                        hdhPayInfo.payName = "惠钱包支付";
                    }else if(salerPayCode == 32){
                        hdhPayInfo.payName = "惠钱包支付";
                    }
                    hdhPayInfo.payCode = dealerPayCode;
                    hdhPayInfo.payTypeSign = '1'; //经销商支付标识
                    hdhPayInfoList[i + len] = hdhPayInfo;
                }
				//商品
                for(var i = 0; i < $(".prodPrice").length; i++){
                    var hdhActivityProduct = {};
                    if($(".prodNames").eq(i).html() == ""){
                        alert("Please select goods");
                        return;
					}
					if($(".prodIds").eq(i).val() == ""){
                        alert("Please select goods");
                        return;
					}
                    if($(".prodPrice").eq(i).val() == ""){
                        alert("Please fill in the commodity price");
                        return;
					}
                    if(!new RegExp("^[0-9]{1,8}$").test($(".prodPrice").eq(i).val()) && !new RegExp("^[0-9]{1,8}[.]{1}[0-9]{0,2}$").test($(".prodPrice").eq(i).val())){
                        alert("Item price format is not correct, the maximum such as:99999999.99");
                        return;
                    }
                    if(!new RegExp("^[0-9]{0,4}$").test($(".mustBuyQty").eq(i).val())){
                        alert("The minimum order quantity is not correct, the maximum is as:9999");
                        return;
                    }
					hdhActivityProduct.prodName = $(".prodNames").eq(i).html();
					hdhActivityProduct.prodId = $(".prodIds").eq(i).val();
					hdhActivityProduct.prodPrice = $(".prodPrice").eq(i).val();
					if($(".prodQty").eq(i).val() != ""){
						hdhActivityProduct.prodQty = $(".prodQty").eq(i).val();
					} else {
                        hdhActivityProduct.prodQty = 0;
					}
                    if($(".mustBuyQty").eq(i).val() != ""){
                        hdhActivityProduct.mustBuyQty = $(".mustBuyQty").eq(i).val();
                    } else {
                        hdhActivityProduct.mustBuyQty = 0;
                    }
					hdhActivityProductList[i] = hdhActivityProduct;
                }
                var ruleType = $("#ruleType").val()
                //坎级
                for(var i = 0; i < $(".disCountName").length; i++){
                    var hdhDiscountInfo = {};
                    if($(".mustContainProd").eq(i).val() == "" && $(".mustContainQty").eq(i).val() != "" && $(".mustContainQty").eq(i).val() != 0){
                        alert("Please select the required item in the order");
                        return;
                    }
                    if($(".mustContainProd").eq(i).val() != "" && $(".mustContainQty").eq(i).val() == ""){
                        alert("Please select the order must include the quantity of goods");
                        return;
                    }
                    if(ruleType == 3)
                    {
                        if($(".activityPieceNum").eq(i).val() == ""){
                            alert("Please select the Activity Piece Num");
                            return;
                        }
                    }else{
                        if($(".activityPrice").eq(i).val() == ""){
                            alert("Please select the activity price");
                            return;
                        }
                        if(!new RegExp("^[0-9]{1,8}$").test($(".activityPrice").eq(i).val()) && !new RegExp("^[0-9]{1,8}[.]{1}[0-9]{0,2}$").test($(".activityPrice").eq(i).val())){
                            alert("activity price format is not correct:99999999.99");
                            return;
                        }
                    }
                    if($(".disCountName").eq(i).val() != "" && $(".disCountId").eq(i).val() != "" && $(".prodDiscountQty").eq(i).val() == ""){
                        alert("Please select the number of giveaways");
                        return;
                    }
                    if($(".prodDiscountQty").eq(i).val() != 0 && $(".disCountName").eq(i).val() == ""){
                        alert("Please select freebies");
                        return;
					}
                    if($(".prodDiscountQty").eq(i).val() != "" && !new RegExp("^[0-9]{1,6}$").test($(".prodDiscountQty").eq(i).val())){
                        alert("The number of gifts is an integer ranging from 1 to 6");
                        return;
                    }
                    if($(".disCountName").eq(i).val() == "" && $(".disCountId").eq(i).val() == "" && $(".discountPrice").eq(i).val() == ""){
                        alert("Please select freebies or fill out the free discount");
                        return;
					}
                    if($(".discountPrice").eq(i).val() != "" &&
                        !new RegExp("^[0-9]{1,8}$").test($(".discountPrice").eq(i).val()) &&
                        !new RegExp("^[0-9]{1,8}[.]{1}[0-9]{0,2}$").test($(".discountPrice").eq(i).val())){
                        alert("Dealer free price format is not correct, as large as:99999999.99");
                        return;
                    }
                    if(ruleType != 3)
                    {
                        if($(".winSalerPrice").eq(i).val() != "" &&
                            !new RegExp("^[0-9]{1,8}$").test($(".winSalerPrice").eq(i).val()) &&
                            !new RegExp("^[0-9]{1,8}[.]{1}[0-9]{0,2}$").test($(".winSalerPrice").eq(i).val())){
                            alert("Platform free price format is not correct, such as the maximum:99999999.99");
                            return;
                        }
					}

                    //20181122 去掉此限制
                    /*
                    if($(".winSalerPrice").eq(i).val() != "" && $(".discountPrice").eq(i).val() != "" ){
                        if(parseFloat($(".winSalerPrice").eq(i).val()) > $(".discountPrice").eq(i).val()) {
                            alert("惠下单承担费用不能超出总减免");
                            return;
                        }
                    } */

                    if($(".disCountName").eq(i).val() != "" && $(".disCountId").eq(i).val() != ""){
                        for(var j = i + 1; j < $(".disCountName").length; j++){
                            if($(".activityPrice").eq(i).val() == $(".activityPrice").eq(j).val()
                                && $(".disCountId").eq(i).val() == $(".disCountId").eq(j).val()){
                                alert("The same order amount under the gift is repeated");
                                return;
                            }
                        }
                    }
                    if($(".winSalerRatio").eq(i).val() == "" && $(".winSalerRatio").eq(i).attr("oldOrNew") == "new"){
                        alert("Please enter HXD charge ratio");
                        return;
                    }
                    if(ruleType != 1)
                    {
                        if($(".doublingMultipleNum").eq(i).val() == ""){
                            alert("Please enter base double scale!");
                            return;
                        }
                        if($(".doublingNum").eq(i).val() == ""){
                            alert("Please enter double times!");
                            return;
                        }
                    }
                    /*if(i > 0 && parseFloat($(".activityPrice").eq(i).val()) <= parseFloat($(".activityPrice").eq(i - 1).val())){
                        alert("坎级订单金额满没有上一级大，请正确填写金额");
                        return;
                    }*/
					//坎级订单必含商品必须从已选商品中选择
					var prodFlag = false;
					for(var j = 0; j < $(".prodPrice").length; j++){
						if($(".mustContainProdId").eq(i).val() == $(".prodIds").eq(j).val()){
							prodFlag = true;
							break;
						}
					}
                    for(var j = 0; j < $(".prodNameHidden").length; j++){
                        if($(".mustContainProd").eq(i).val() == $(".prodNameHidden").eq(j).val()){
                            prodFlag = true;
                            break;
                        }
                    }
					if(!prodFlag && $(".mustContainProd").eq(i).val() != ""){
						alert("Threshold order required items must be selected from selected items");
						return;
					}
                    hdhDiscountInfo.mustContainProd = $(".mustContainProd").eq(i).val();
                    hdhDiscountInfo.mustContainProdId = $(".mustContainProdId").eq(i).val();
                    hdhDiscountInfo.mustContainQty = $(".mustContainQty").eq(i).val();
                    hdhDiscountInfo.disCountName = $(".disCountName").eq(i).val();
                    hdhDiscountInfo.disCountId = $(".disCountId").eq(i).val();
                    hdhDiscountInfo.prodQty = $(".prodDiscountQty").eq(i).val();
                    hdhDiscountInfo.discountPrice = $(".discountPrice").eq(i).val();
                    hdhDiscountInfo.winSalerRatio = $(".winSalerRatio").eq(i).val();
                    if(ruleType == 3)
                    {
                        hdhDiscountInfo.activityPieceNum= $(".activityPieceNum").eq(i).val();
                        hdhDiscountInfo.winSalerRatio = $(".winSalerRatio").eq(i).val();
                    }else{
                        hdhDiscountInfo.activityPrice = $(".activityPrice").eq(i).val();
                        hdhDiscountInfo.winSalerRatio = $(".winSalerRatio").eq(i).val();
                        hdhDiscountInfo.winSalerPrice = $(".winSalerPrice").eq(i).val();
                    }
                    if(ruleType != 1 )
                    {
                        hdhDiscountInfo.doublingMultipleNum=$(".doublingMultipleNum").eq(i).val()
                        hdhDiscountInfo.doublingNum=$(".doublingNum").eq(i).val()
                    }

                    hdhDiscountInfo.oldOrNew = $(".winSalerRatio").eq(i).attr("oldOrNew");
                    hdhDiscountInfo.winSalerPrice = $(".winSalerPrice").eq(i).val();
                    hdhDiscountInfoList[i] = hdhDiscountInfo;
                }
				if(errMsg != ""){
				    alert(errMsg);
				    return;
				}
                //批量导入商品
                var va = $("#excelFile").val();
                if(va) {
                    if (!/\.(xlsx|xls)$/.test(va)) {
                        alert("The uploaded file must be Excel");
                        return;
                    }
                }

                var extendText = $("#extendText").val();

                if(extendText!=null&&extendText!=""&&extendText.length>200){
                    alert("The maximum length of customized promotion copy is 200");
                    return;
                }

                //新增品牌活跃门店
                var brandStoreList = new Array();
                $("input[name='storeActiveNums']").each(function (i) {
                    var brandStoreActive = {};
                    brandStoreActive.storeActiveNum = $("input[name='storeActiveNums']").eq(i).val();
                    brandStoreActive.brandName = $("input[name='brandNames']").eq(i).val();
                    brandStoreList[i] = brandStoreActive;
                });

                $("#hdhActivityProductList").val(JSON.stringify(hdhActivityProductList));
                $("#hdhDiscountInfoList").val(JSON.stringify(hdhDiscountInfoList));
                $("#hdhPayInfoList").val(JSON.stringify(hdhPayInfoList));
                $("#brandStoreList").val(JSON.stringify(brandStoreList));
				document.forms[0].action = "${ctx}/crm/crmHdhActivityAction.do?method=saveOrUpdateHdhActivity";
				document.forms[0].submit();
            })

        });

        var options={
            url: '${ctx}/crm/crmHdhActivityAction.do?method=readExcelProd',
            type: 'POST',
            success:function(data){
                $("#excelProdHidden").html("");
                if(data != null){
                    var obj = eval('(' + data + ')');
                    var excelProdList = obj.excelProdList;
                    for(var i=0; i<excelProdList.length; i++){
                        $("#excelProdHidden").append("<input type='hidden' class='prodNameHidden' value='"+excelProdList[i].prodName+"' />" +
                            "<input type='hidden' class='prodSkuHidden' value='"+excelProdList[i].sku+"' />");
                    }
                }
            }
        }
        //读取Excel里的商品
        function excelFileChange() {
            $("#activityForm").ajaxSubmit(options);
        }

        //添加坎级优惠
        function addDiscount() {
            var ruleType =$("#ruleType").val()
            var dicountModel = $("#dicountModel").html();
            if(ruleType == 1)
            {
                $("#dicount").append("<tr>" +
                    "<td></td>" +
                    "<td>It must be included in the order<input id='mustContainProd' class='select_but mustContainProd' onclick='selectPoiDisCount(this)' readonly='true' value=''/><input id='mustContainProdId' class='mustContainProdId' type='hidden' value=''/></td>" +
                    "<td><input type='number' style='width: 70px' class='mustContainQty' value=''/>Piece</td>" +
                    "<td>The order amount is over<input type='number' style='width: 70px;' class='activityPrice' value='' oninput='winSalerCount(this)' />yuan</td>" +
                    "<td>Reduction of<input type='number' style='width: 70px' class='discountPrice' value='' onblur='discountCompare(this)'/>yuan<font color='red'></font></td>" +
                    "<td>Gift<input id='disCountName' class='select_but disCountName' onclick='selectPoiDisCount(this)' readonly='true' value=''/><input id='disCountId' class='disCountId' type='hidden' value=''/></td>" +
                    "<td>Quantity<input type='number' style='width: 70px' class='prodDiscountQty' value=''/></td>" +
                    "<td>Proportion of Fees Borne by Hui Order<input type='number' style='width: 70px' class='winSalerRatio' value='0' min='0' max='100' step='0.01' oninput='winSalerCount(this)'/>%</td>" +
                    "<td>Borne fees of Hui Order <input type='number' style='width: 70px' class='winSalerPrice' value='' readonly='readonly' disabled='disabled'/>yuan<font color='red'></font></td>"+
                    "<td width='10%'><input type='button' value='Delete Threshold' onclick='deleteDiscount(this)' /></td>" +
                    "</tr>");
            }

        }
        //删除坎级优惠
        function deleteDiscount(obj) {
            var tab = document.getElementById('dicount');
            //获取tr对象;
            var tr = obj.parentNode.parentNode;
            if (tab.rows.length > 1) {
                //tr.parentNode，指的是，table对象;移除子节点;
                tr.parentNode.removeChild(tr);
            }
        }
        //选择赠品
        function selectPoiDisCount(obj) {
            var form=document.forms[0];
            var dealerCode = $.trim(form.dealerCode.value);
            if(dealerCode == ''){
                alert("Please select dealer");
                return false;
            }
            var dealerId = {};
            dealerId.dealerCode = dealerCode;
            var disCountName = $(obj).val();
            var disCountId = $(obj).next().val();
            openDialogList('${ctx}','0','poiDealerProd',disCountId,disCountName,'',function(v){
                if(v){
                    $(obj).next().val(v.id);
                    $(obj).val(v.text);
                }
            },'',dealerId);
        }
        //选择经销商商品
        function selectPoiProd(obj) {
            var hdhActivityProductList = new Array();
            for(var i = 0; i < $(".prodPrice").length; i++){
                var hdhActivityProduct = {};
                hdhActivityProduct.prodName = $(".prodNames").eq(i).html();
                hdhActivityProduct.prodId = $(".prodIds").eq(i).val();
                hdhActivityProduct.prodPrice = $(".prodPrice").eq(i).val();
                if($(".prodQty").eq(i).val() != ""){
                    hdhActivityProduct.prodQty = $(".prodQty").eq(i).val();
                } else {
                    hdhActivityProduct.prodQty = 0;
                }
                hdhActivityProductList[i] = hdhActivityProduct;
            }
            var form=document.forms[0];
            var dealerCode = $.trim(form.dealerCode.value);
            if(dealerCode == ''){
                alert("Please select dealer");
                return false;
            }
            var dealerId = {};
            dealerId.dealerCode = dealerCode;
            var prodName = form.prodName.value;
            var prodId = form.prodId.value;
            openDialogList('${ctx}','1','poiDealerProd',prodId,prodName,'',function(v){
                if(v){
                    //追加显示商品
					$("#prods").html("<tr id='selectProd'>"+ $("#selectProd").html() +"</tr>");
                    $("#prodId").val(v.id);
                    $("#prodName").val(v.text);
                    var prods = v.text.split(",");
                    var prodIds = v.id.split(",");
                    if(prods.length == 0 || (prods.length == 1 && prods[0] == "")){

					} else {
                        for (var i = 0; i < prods.length; i++){
                            var prodPrice = "";
                            var prodQty = 0;
                            var mustBuyQty = 0;
                            for(var j = 0; j < hdhActivityProductList.length; j++){
                                if(hdhActivityProductList[j].prodId == prodIds[i]){
                                    prodPrice = hdhActivityProductList[j].prodPrice;
                                    prodQty = hdhActivityProductList[j].prodQty;
                                    if(typeof(hdhActivityProductList[j].mustBuyQty) != "undefined"){
                                        mustBuyQty = hdhActivityProductList[j].mustBuyQty;
									}
                                    break;
                                }
                            }
                            $("#prods").append("<tr class='removeChild'><td><input type='hidden' class='prodIds' value='"+prodIds[i]+"' /></td><td class='prodNames'>"+ prods[i] +"</td>" +
                                "<td><input type='hidden' class='prodSku' />Price：<input type='text' class='prodPrice' style='width:70px' value='"+prodPrice+"' />yuan</td>" +
                                "<td>Maximum purchase:<input type='text' class='prodQty' style='width:70px' value='"+prodQty+"'></td><td>minimum order quantity:" +
                                "<input type='text' class='mustBuyQty' style='width:70px' value='"+mustBuyQty+"' />Piece</td></tr>");
                        }
					}
                }
            },'',dealerId);
		}
		//删除商品
		/*function delProd(obj, prodId, prodName){
            //获取tr对象;
            var tr = obj.parentNode.parentNode;
			tr.parentNode.removeChild(tr);
			var newProdName = "";
			var newProdId = "";
            var nameList = $("#prodName").val().split(",")
			for(var i = 0; i < nameList.length; i++){
                if(nameList[i] != prodName ){
                    newProdName += ("," + nameList[i]) ;
				}
			}
			if(newProdName.length != 0){
                $("#prodName").val(newProdName.substring(1));
			} else {
                $("#prodName").val("");
			}
            var idList = $("#prodId").val().split(",")
            for(var i = 0; i < idList.length; i++){
                if(idList[i] != prodId ){
                    newProdId += ("," + idList[i]) ;
                }
            }
            if(newProdId.length != 0){
                $("#prodId").val(newProdId.substring(1));
            } else {
                $("#prodId").val("");
            }

		}*/

        //选择经销商
        function selectPoi(){
            var form=document.forms[0];
            var dealerCode = $("#dealerCode").val();
            openDialogList('${ctx}','0','poiDealerList',form.dealerName.value,form.dealerCode.value,'',function(v){
                if(v){
                    form.dealerCode.value=v.id;
                    form.dealerName.value=v.text;
                    $("#prods").html("<tr id='selectProd'>"+ $("#selectProd").html() +"</tr>");
                    $("#prodId").val("");
                    $("#prodName").val("");
                    for(var i = 0; i < $(".disCountName").length; i++){
                        $(".disCountName").eq(i).val("");
                        $(".disCountId").eq(i).val("");
                    }
                }
            });
        }
        function openUploadfileWindow(grp,tid) {
            var url = '${ctx}/uploadIframe.jsp';
            $("#uploadIframe").attr("src",url); //设置IFRAME的SRC;
            $("#dialog").dialog({
                bgiframe: true,
                resizable: true, //是否可以重置大小
                height: 283, //高度
                width: 800, //宽度
                draggable:true, //是否可以拖动。
                title: "Pic Upload",
                modal: true,
                position:['center','center'],
                open: function (e) {  //打开的时候触发的事件

                },
                close: function () { //关闭Dialog时候触发的事件
                    var ofrm1 = document.getElementById("uploadIframe").document;
                    //alert(window.frames["uploadIframe"].contentWindow.name);
                    var returnVal = "";
                    if (ofrm1==undefined)
                    {
                        var uploadform = window.frames["uploadIframe"].document;
                        returnVal = uploadform.getElementById("returnVal").value;
                    }
                    else
                    {
                        returnVal = document.frames["uploadIframe"].document.getElementById("returnVal").value;
                    }
                    if(returnVal!=''&& returnVal!=undefined){
                        var data = $.parseJSON(returnVal);
                        $('#' + tid).val(data.downloadURL);
                        //$('#' + tid).val(returnVal.split("@")[0]);
                    }
                }
            });
        }
        //查看图片
        function viewPic(pid){
            if( $("#" + pid).val() == ''){
                return ;
            }
            var oPa=$('.opa');
            var oImg=$('.img');
            oPa.addClass('on');
            oImg.addClass('on');
            oImg.css({'background': 'url('+ $('#' + pid).val() +') no-repeat center center',"width":"100%","height":"100%","background-position":"50%","background-size":"contain"});
            oImg.addClass('on');
            oImg.click(function(){
                oPa.removeClass('on');
                oImg.removeClass('on');
            });
        }

        function openUploadVideWindow(grp,tid,fileId) {
            var url = '${ctx}/hdhUploadVideoIframe.jsp';
            $("#uploadIframe").attr("src",url); //设置IFRAME的SRC;
            $("#dialog").dialog({
                bgiframe: true,
                resizable: true, //是否可以重置大小
                height: 283, //高度
                width: 800, //宽度
                draggable:true, //是否可以拖动。
                title: "Upload video",
                modal: true,
                position:['center','center'],
                open: function (e) {  //打开的时候触发的事件

                },
                close: function () { //关闭Dialog时候触发的事件
                    var ofrm1 = document.getElementById("uploadIframe").document;
                    //alert(window.frames["uploadIframe"].contentWindow.name);
                    var returnVal = "";
                    if (ofrm1==undefined)
                    {
                        var uploadform = window.frames["uploadIframe"].document;
                        returnVal = uploadform.getElementById("returnVal").value;
                    }
                    else
                    {
                        returnVal = document.frames["uploadIframe"].document.getElementById("returnVal").value;
                    }
                    if(returnVal!=''&& returnVal!=undefined){
                        var data = $.parseJSON(returnVal);
                        $('#' + tid).val(data.downloadURL);
                        $('#' + fileId).val(data.newFileName);
                        //$('#' + tid).val(returnVal.split("@")[0]);
                    }
                }
            });
        }
		//清空图片
        function clearValue(tid) {
            $('#' + tid).val("");
        }
        //查看视频
        function viewVideo(pid){
            if( $("#" + pid).val() == ''){
                return ;
            }
            window.open($("#" + pid).val());
        }
        //选择销售区域
        function selectCity() {
            var form = document.forms[0];
            if($("#newActivity").val() != 1){
                alert("This activity cannot be edited Sales Area");
                return;
			}
            openDialogList('${ctx}', '0' , 'hdhSaleArea', form.areaCode.value, form.areaName.value,'',function(v){
                if (v) {
                    form.areaCode.value = v.id;
                    form.areaName.value = v.text;
                }
            });
        }

        //选择活动类型
        function  selectActivityType() {
            var form = document.forms[0];
            openDialogList('${ctx}', '1' , 'activityType', form.dictItemId.value, form.itemName.value,'',function(v){
                if (v) {
                    form.dictItemId.value = v.id;
                    form.itemName.value = v.text;
                }
            });
        }
        function resetBrand() {
			$("#brandStoreViewList").hide();
            $("#brandStoreViewList").remove();
            $("#brandViewList").show();
        }
        //校验活动名称是否已存在
        function checkActivityName(id,name) {
            var url =  "${ctx}/crm/crmHdhActivityAction.do?method=checkHdhActivity";
            $.ajax({
                type:"post",
                url:url,
                async: false,
                data:{id:id,name:name},
                success:function(data) {
                    if(data != "success") {
                        errMsg = "Activity Name already exist！";
                    }
                },
                error:function () {
                    errMsg = "Activity Name already exist！";
                }
            })
        }
	</script>
	<%--<%@ include file="/commons/mdmdialog.jsp"%>--%>
</head>

<body onLoad="WindowSollAuto()" onResize="WindowSollAuto()" >
<jsp:include page="/commons/messages.jsp" flush="true"></jsp:include>
<div style="display:none;overflow:hidden;padding:3px" id="dialog">
	<iframe frameborder="no" border="0" marginwidth="0" marginheight="0" id="uploadIframe" name="uploadIframe" scrolling="no"  width="100%" height="245"></iframe>
</div>
<html:form action="/crm/crmHdhActivityAction.do?method=saveOrUpdateHdhActivity" method="post" enctype="multipart/form-data" styleId="activityForm">

	<div class="bosom_one">
		<div class="bosom_top">
			<span class="left"></span>
			<h4>Update the Group-Buying Meeting</h4>
			<div class='MenuList'>
				<a href="javascript:;" id="save">save</a>
				<a href="${ctx}/crm/crmHdhActivityAction.do?method=hdhActivityList">back</a>
			</div>
			<span class="right"></span>
		</div>
		<div class="bosom_side">
			<div class="casing">
				<div class="caput">
					<span class="left"></span><span class="right"></span>
				</div>
				<div class="viscera" id="SollAuto">
					<div class="sheet_div">
						<table class="list_add" id="timespan">
							<tr>
								<td class="formTable" width="20%"><font color="#FF0000">*</font>Activity Name：</td>
								<td align="left" width="70%">
									<html:text property="name" styleId="name" value="${hdhActivity.name}" /><label style="color:#FF0000"></label>
									<html:hidden property="id" styleId="id" value="${hdhActivity.id}"/>
									<html:hidden property="status" styleId="status" value="${hdhActivity.status}"/>
									<html:hidden property="audit" styleId="audit" value="${hdhActivity.audit}"/>
									<html:hidden property="auditBy" styleId="auditBy" value="${hdhActivity.auditBy}"/>
									<html:hidden property="auditTime" styleId="auditTime" value="${hdhActivity.auditTime}"/>
									<html:hidden property="noPassReason" styleId="noPassReason" value="${hdhActivity.noPassReason}"/>
									<html:hidden property="newActivity" styleId="newActivity" value="${hdhActivity.newActivity}"/>
									<html:hidden property="created" styleId="created" value="${hdhActivity.created}" />
									<html:hidden property="createdBy" styleId="createdBy" value="${hdhActivity.createdBy}" />
									<html:hidden property="updated" styleId="updated" value="${hdhActivity.updated}" />
									<html:hidden property="updatedBy" styleId="updatedBy" value="${hdhActivity.updatedBy}" />
								</td>
							</tr>
							<tr>
								<td class="formTable" width="1%"><font color='red'>*</font>Activity Start Time：</td>
								<td align="left" width="1%">
									<input id="startTime" name="startTime" class="Wdate" type="text" title="It cannot be modified if the activity is already started!" value="${hdhActivity.startTime}" readonly="true"
										<c:if test="${empty hdhActivity.startTime or now<hdhActivity.startTime}">
											onFocus="WdatePicker({minDate:'new Date()',maxDate:'#F{$dp.$D(\'endTime\')||\'2020-10-01\'}',dateFmt:'yyyy-MM-dd HH:mm:ss','lang':'en'})"
										</c:if>
									 /><label style="color:#FF0000"></label>
								</td>
							</tr>
							<tr>
								<td class="formTable" width="1%"><font color='red'>*</font>Activity End Time：</td>
								<td align="left" width="1%">
									<input id="endTime" name="endTime" class="Wdate" value="${hdhActivity.endTime}" type="text" readonly="true" onFocus="WdatePicker({minDate:'#F{$dp.$D(\'startTime\')}',maxDate:'2020-10-01',dateFmt:'yyyy-MM-dd HH:mm:ss','lang':'en'})" /><label style="color:#FF0000"></label>
								</td>
							</tr>
							<tr id="dealerCode">
								<td class="formTable" width="1%"><font color='red'>*</font>Distributor Name：</td>
								<td align="left" width="1%">
									<html:text property="dealerName" styleId="dealerName" styleClass="select_but" onclick="selectPoi()" readonly="true" value="${hdhActivity.dealerName}" />
									<html:hidden property="dealerCode" styleId="dealerCode" value="${hdhActivity.dealerCode}" />
								</td>
								<td>&nbsp;</td>
							</tr>
							<tr>
								<td class="formTable" width="1%"><font color="#FF0000">*</font>Sales Area：</td>
								<td align="left" width="1%">
									<html:text  property="areaName" styleId="areaName" styleClass="select_but" onclick="selectCity()" readonly="true" value="${hdhActivity.areaName}" />
									<html:hidden  property="areaCode" styleId="areaCode" value="${hdhActivity.areaCode}"/>
								</td>
							</tr>
							<tr>
								<td class="formTable" width="1%"><font color="#FF0000">*</font>Group-Buying Meeting Type：</td>
								<td align="left" width="1%">
									<select id="activityType" name="activityType">
										<option value="1" <c:if test="${hdhActivity.activityType eq '1'}">selected</c:if>>Retail</option>
										<option value="2" <c:if test="${hdhActivity.activityType eq '2'}">selected</c:if>>Wholesale</option>
									</select>
								</td>
							</tr>
							<tr>
								<td class="formTable" width="1%"><font color="#FF0000">*</font>Type of the Activity：</td>
								<td align="left" width="1%">
									<html:text  property="itemName" styleId="itemName" styleClass="select_but"  readonly="true" onclick="selectActivityType()" value="${hdhActivityDict.itemName}" />
									<html:hidden  property="dictItemId" styleId="dictItemId" value="${hdhActivityDict.dictItemId}" />
								</td>
							</tr>
							<tr>
								<td class="formTable" width="1%"><font color='red'>*</font>Rate：</td>
								<td align="left" width="1%">
									<html:text property="hdhRate" styleId="hdhRate" readonly="true" value="${hdhActivity.hdhRate * 100}" />%
								</td>
								<td>&nbsp;</td>
							</tr>
							<tr>
								<td class="formTable" width="1%"><font color='red'>*</font>Rebate Rates：</td>
								<td align="left" width="1%">
									<html:text property="hdhRebatePercent" styleId="hdhRebatePercent" value="${hdhActivity.hdhRebatePercent * 100}"  />%
								</td>
								<td>&nbsp;</td>
							</tr>
							<tr>
								<td class="formTable" width="1%"><font color="#FF0000">*</font>Whether an Offline Rebate：</td>
								<td align="left" width="1%">
									<html:select name="ec" property="activityOfflineRebate" styleId="activityOfflineRebate" value="${hdhActivity.activityOfflineRebate}">
										<html:option value="2">yes</html:option>
										<html:option value="1">no</html:option>
									</html:select>
								</td>
							</tr>
							<tr>
								<td class="formTable" width="20%">Total Active Customers：</td>
								<td align="left" width="70%">
									<html:text property="activeStoreQty" styleId="activeStoreQty" value="${hdhActivity.activeStoreQty}" />home</label>
								</td>
							</tr>
							<tr>
								<td class="formTable" width="20%">GMV：</td>
								<td align="left" width="70%">
									<html:text property="GVM" styleId="GVM" value="${hdhActivity.GVM}" />yuan</label>
								</td>
							</tr>
							<tr>
								<td class="formTable" width="1%">Rebate：</td>
								<td align="left" width="1%">
									<html:text property="callBackProfits" styleId="callBackProfits" value="${hdhActivity.callBackProfits * 100}" />%
								</td>
								<td>&nbsp;</td>
							</tr>
							<tr>
								<td class="formTable" width="1%">Brand active：</td>
								<td><input type="button" value="reset" onclick="resetBrand()"/></td>
							</tr>
							<tr id="brandStoreViewList">
								<td align="left" width="1%" >
									<c:forEach var="brand" items="${brandStoreList}" varStatus="status">
										<input type="text" style='width: 80px' name="brandNames" value="${brand.brandName}" readonly="true">&nbsp;&nbsp;Total Active Customers：
										<input type="text" style='width: 70px' name="storeActiveNums" value="${brand.storeActiveNum}">&nbsp;&nbsp;home <br/>
									</c:forEach>
								</td>
							</tr>
							<tr id="brandViewList" style="display: none;">
								<td align="left" width="1%" >
									<c:forEach var="brand" items="${brandList}" varStatus="status">
										<input type="text" style='width: 80px' name="brandNames" value="${brand.brandName}" readonly="true">&nbsp;&nbsp;Total Active Customers：
										<input type="text" style='width: 70px' name="storeActiveNums" value="${brand.storeActiveNum}">&nbsp;&nbsp;home <br/>
									</c:forEach>
								</td>
							</tr>
							<tr>
								<td class="formTable" width="1%"><font color='red'>*</font>Activity Photos</td>
								<td align="left" colspan="3" width="80%">
									<input readonly type="text" style="width:618px;" name="bannerImg" id="bannerImg" value="${hdhActivity.bannerImg}" />
									<input type="button" value="Clear All" style="width:60px;" onclick="javascript:clearValue('bannerImg');"/>&nbsp;
									<input type="button" value="Upload a File" onclick="javascript:openUploadfileWindow('${grp}','bannerImg');"/>
									&nbsp;<input type="button" value="To view" style="width:40px;" onclick="javascript:viewPic('bannerImg');"/>
								</td>
							</tr>
							<tr>
								<td class="formTable" width="1%">Explanatory picture of Group-Buying Meeting</td>
								<td align="left" colspan="3" width="80%">
									<input readonly type="text" style="width:618px;" name="activityImg" id="activityImg" value="${hdhActivity.activityImg}" />
									<input type="button" value="Clear All" style="width:60px;" onclick="javascript:clearValue('activityImg');"/>&nbsp;
									<input type="button" value="Upload a File" onclick="javascript:openUploadfileWindow('${grp}','activityImg');"/>
									&nbsp;<input type="button" value="To view" style="width:40px;" onclick="javascript:viewPic('activityImg');"/>
								</td>
							</tr>
							<tr>
								<td class="formTable" width="1%">Promotion Video</td>
								<td align="left" colspan="3" width="80%">
									<input readonly type="text" style="width:618px;" name="extendVideo" id="extendVideo" value="${hdhActivity.extendVideo}" />
									<input type="button" value="Clear All" style="width:60px;" onclick="javascript:clearValue('extendVideo');"/>&nbsp;
									<input type="button" value="Upload a File" onclick="javascript:openUploadVideWindow('${grp}','extendVideo','videoFileId');"/>
									&nbsp;<input type="button" value="To view" style="width:40px;" onclick="javascript:viewVideo('extendVideo');"/>
									<input readonly type="hidden" style="width:618px;" name="videoFileId" id="videoFileId" value="${hdhActivity.videoFileId}" />
									<span style="padding-left:5px;color:red;">The video format is MP4, and the video size cannot exceed 30M</span>
								</td>
							</tr>
							<tr>
								<td class="formTable" width="1%"><font color='red'>*</font>Payment Method of the Customer：</td>
								<td align="left" width="1%">
									<c:forEach var="item" items="${hdhPayInfoList}" varStatus="status">
										<c:if test="${item.payTypeSign eq '0'}">
											<span style="color:#FF0000">
												<input type="hidden" class="salerPayWay" name="salerPayWay" value="${item.payCode}">
												<c:if test="${item.payName eq '支付宝支付'}">
													Alipay Payment
												</c:if>
												<c:if test="${item.payName eq '快捷支付'}">
													Quick Payment
												</c:if>
												<c:if test="${item.payName eq '线下转账'}">
													Offline Transfer
												</c:if>
												<c:if test="${item.payName eq '惠钱包支付'}">
													Huipay
												</c:if>
												<c:if test="${item.payName eq 'POS机刷卡'}">
													POS Brusher Card
												</c:if>
												<c:if test="${item.payCode eq '31'}">
													(Webank)
												</c:if>
												<c:if test="${item.payCode eq '32'}">
													(Ping An Bank)
												</c:if>
											</span>|
										</c:if>
									</c:forEach>
								</td>
								<td colspan="4">&nbsp;</td>
							</tr>
							<tr>
								<td class="formTable" width="1%"><font color='red'>*</font>Payment Method of the Distributor：</td>
								<td align="left" width="1%">
									<c:forEach var="item" items="${hdhPayInfoList}" varStatus="status">
										<c:if test="${item.payTypeSign eq '1'}">
											<span style="color:#FF0000">
												<input type="hidden" class="dealerPayWay" name="dealerPayWay" value="${item.payCode}">
												<c:if test="${item.payName eq '支付宝支付'}">
													Alipay Payment
												</c:if>
												<c:if test="${item.payName eq '快捷支付'}">
													Quick Payment
												</c:if>
												<c:if test="${item.payName eq '线下转账'}">
													Offline Transfer
												</c:if>
												<c:if test="${item.payName eq '惠钱包支付'}">
													Huipay
												</c:if>
												<c:if test="${item.payName eq 'POS机刷卡'}">
													POS Brusher Card
												</c:if>
												<c:if test="${item.payCode eq '31'}">
													(Webank)
												</c:if>
												<c:if test="${item.payCode eq '32'}">
													(Ping An Bank)
												</c:if>
											</span>|
										</c:if>
									</c:forEach>
								</td>
								<td colspan="4">&nbsp;</td>
							</tr>
						</table>
						<table class="list_add" id="addDiscount">
							<tr>
								<td class="formTable" width="1%">
									Threshold Promotion：
									<html:select styleId="ruleType" property="activeRuleType" value="${hdhActivity.activityRuleType}" disabled="true">
										<html:option value="1"  >Make a reduction and give a fulfil-quota gift according to the amount</html:option>
										<html:option value="2" >Double the reduction and fulfil-quota gift according to the amount</html:option>
										<html:option value="3" >Double the reduction and fulfil-quota gift according to number of pieces</html:option>
									</html:select>
									<input type="hidden" name="ruleType" value="${hdhActivity.activityRuleType}">
									<html:hidden property="hdhActivityProductList" styleId="hdhActivityProductList" value="${hdhActivityProductList}"/>
									<html:hidden property="hdhDiscountInfoList" styleId="hdhDiscountInfoList" value="${hdhDiscountInfoList}" />
									<html:hidden property="hdhPayInfoList" styleId="hdhPayInfoList" value="${hdhPayInfoList}" />
									<html:hidden property="brandStoreList" styleId="brandStoreList" value="${brandStoreList}" />
								</td>
								<c:if test="${hdhActivity.activityRuleType == 1}">
									<td width="10%"><input type='button' id="addDiscountButton" value='Increased threshold' onclick='addDiscount()' /></td>
								</c:if>
								<td>
									Bulk Import：
									<html:file property="excelFile" styleId="excelFile" onchange="excelFileChange()" />
								</td>
								<td style="font-size:12px;"><a href="${ctx}/import/crmHdhProduct.xlsx" style="color: red;">Import Template</a></td>
							</tr>
						</table>
						<table class="list_add" id="dicount">
							<c:forEach var="item" items="${hdhDiscountInfoList}" varStatus="status">
								<tr>
									<td></td>
									<td>It must be included in the order
										<input  id='mustContainProd' class='select_but mustContainProd' readonly='true' value='${item.mustContainProd}' readonly='readonly' disabled='disabled'/>
										<input type='hidden' Class='mustContainProdId' id='mustContainProdId' value='${item.mustContainProdId}'/>
									</td>
									<td>
										<input type='number' style='width: 70px' class='mustContainQty' value='${item.mustContainQty}' readonly='readonly' disabled='disabled'/>Piece
									</td>
									<c:if test="${hdhActivity.activityRuleType == 3}">
										<td>The number of orders is full
											<input type='number' style='width: 70px' class='activityPieceNum' value='${item.activityPieceNum}' readonly='readonly' disabled='disabled'/>Piece
										</td>
									</c:if>
									<c:if test="${hdhActivity.activityRuleType != 3}">
										<td>The order amount is over
											<input type='number' style='width: 70px' class='activityPrice' value='${item.activityPrice}' readonly='readonly' disabled='disabled'/>yuan
										</td>
									</c:if>
									<td>
										<c:if test="${hdh.activityRuleType != 1}">
										Always Vertical reduction
									    </c:if>
										<c:if test="${hdh.activityRuleType == 1}">
											Reduction of
										</c:if>
										<input type='number' style='width: 70px' class='discountPrice' value='${item.discountPrice}' readonly='readonly' disabled='disabled'/>yuan
										<font color='red'></font>
									</td>
									<td>Gift
										<input id='disCountName' class='select_but disCountName' value='${item.prodName}' readonly='readonly' disabled='disabled'/>
										<input type='hidden' Class='disCountId' id='disCountId' value='${item.prodId}'/>
									</td>
									<td>Quantity
										<input type='number' style='width: 70px' class='prodDiscountQty' value='${item.prodQty}' readonly='readonly' disabled='disabled'/>
									</td>
									<td>Proportion of Fees Borne by Hui Order
										<input type='number' style='width: 70px' class='winSalerRatio' value='${item.winSalerRatio}' readonly='readonly' disabled='disabled' oldOrNew='old'/>%
									</td>
									<c:if test="${hdhActivity.activityRuleType != 3}">
										<td>Borne fees of Hui Order
											<input type='number' style='width: 70px' class='winSalerPrice' value='${item.winSalerPrice}' readonly='readonly' disabled='disabled'/>yuan
											<font color='red'></font>
										</td>
									</c:if>
									<c:if test="${hdhActivity.activityRuleType != 1}">
										<td>Double the base ratio
											<input type='number' style='width: 70px' class='doublingMultipleNum' value='${item.doublingMultipleNum}' readonly='readonly' disabled='disabled'/>times
											<font color='red'></font>
										</td>
										<td>Doubling the number of
											<input type='number' style='width: 70px' class='doublingNum' value='${item.doublingNum}' readonly='readonly' disabled='disabled'/>time
											<font color='red'></font>
										</td>
									</c:if>

								</tr>
							</c:forEach>
						</table>
						<table class="list_add" id="prods">
							<tr id="selectProd">
								<td class="formTable" width="22%"><font color="#FF0000">*</font>Activities Goods：</td>
								<td>
									<html:text property="prodName" styleId="prodName" value="${prodName}" styleClass="select_but" onclick="selectPoiProd(this)" readonly="true" />
									<html:hidden property="prodId" styleId="prodId" value="${prodId}" />
								</td>

							</tr>
							<c:forEach var="item" items="${hdhActivityProductList}" varStatus="status">
								<tr class="removeChild">
									<td><input type="hidden" class='prodIds' value="${item.prodId}" /></td>
									<td class='prodNames'>${item.prodName}</td>
									<td>Price:&nbsp;&nbsp;<input type='text' class='prodPrice' style='width:70px' value="${item.prodPrice}" />yuan</td>
									<td>Maximum purchase:&nbsp;&nbsp;<input type='text' class='prodQty' style='width:70px' value="${item.prodQty}" /></td>
									<td>minimum order quantity:&nbsp;&nbsp;<input type='text' class='mustBuyQty' style='width:70px' value="${item.mustBuyQty}" /></td>
									<%--<td><input type='button'  value='删除商品' onclick="delProd(this, '${item.prodId}', '${item.prodName}')" /></td>--%>
								</tr>
							</c:forEach>
						</table>
						<table class="list_add">
							<tr>
								<td class="formTable" width="1%">Number of orders that can be placed：</td>
								<td><input name="upperNum" id="upperNum" value="${hdhActivity.upperNum}" readonly="readonly"/></td>
								<td colspan="4">&nbsp;</td>
							</tr>
							<tr>
								<td class="formTable" width="1%">Order Amount Limit：</td>
								<td><input name="upperPrice" id="upperPrice" value="${hdhActivity.upperPrice}" readonly="readonly"/>yuan</td>
								<td colspan="4">&nbsp;</td>
							</tr>
							<tr>
								<td class="formTable" width="1%">
									Customized Promotion Paperwork：
								</td>
								<td align="left" width="20%">
									<html:textarea cols="60" rows="5" property="extendText" styleId="extendText" value="${hdhActivity.extendText}" />
									The separator is && with a maximum of 200 characters. Optional.
								</td>
								<td>&nbsp;</td>
							</tr>
						</table>
					</div>
				</div>
				<div style="display: none" id="excelProdHidden"></div>
				<div class="trail">
					<span class="fleft"></span><span class="fright"></span>
				</div>
			</div>
		</div>
		<div class="bosom_bottom">
			<span class="left"></span><span class="right"></span>
		</div>
	</div>
</html:form>
<div class="opa">
	<div class="img" />
</div>
<script type="text/javascript">

    var isxtreeFlag = typeof(dialog_xtree) == 'undefined';
    var dialog_xtree;
    if(isxtreeFlag){
        dialog_xtree = {};
        dialog_xtree["hasWincModalDialog"] = false;
        dialog_xtree["window_showModalDialog"] = window.showModalDialog;

        window.showModalDialog = function(src,obj,paramString,callback,title){
            var cb = (typeof(callback) == 'function');

            if (!!window.ActiveXObject || ("ActiveXObject" in window) || ( window.navigator.appCodeName.toLowerCase == "mozilla" && window.navigator.appVersion.indexOf('11') != -1) || !cb){//IE

                var result = dialog_xtree["window_showModalDialog"].call(window,src,obj,paramString);
                if(cb){
                    callback(result);
                    return;
                }else{
                    return result;
                }
            }

            var params = [];
            if(paramString){
                paramString = paramString.replace(/\s/ig,"");
                params = paramString.split(";");
            }

            var height;
            var width;
            for(var i = 0 ; i< params.length ; i++){
                var param = params[i];
                if(param.indexOf("dialogHeight:") == 0){
                    height = param.replace(/dialogHeight:/ig,"");
                    height = height.replace(/px/ig,"");;
                }
                if(param.indexOf("dialogWidth:") == 0){
                    width = param.replace(/dialogWidth:/ig,"");
                    width = width.replace(/px/ig,"");;
                }
            }

            height = height || "50%";
            width = width || "50%";

            $(".dialog_xtree_dialog").remove();
            $("body").append("<div class='dialog_xtree_dialog'></div>");

            if(!title){
                title = "Please Select";
            }

            dialog_xtree["modalDialog"] = $(".dialog_xtree_dialog");
            dialog_xtree["modalDialog"].attr("title",title);
            dialog_xtree["modalDialog"].html($("<iframe name='modalDialog' width='98%' height='99%' style='border:1px solid #ccc;-webkit-overflow-scrolling:touch' />").attr("src", src)).dialog({
                modal: true,
                height:height,
                width:width,
                close:function(event, ui){
                    var frameDialog = window.frames.modalDialog;
                    if(frameDialog.onunload){
                        frameDialog.onunload();
                        dialog_xtree["closeModalDialogResult"](frameDialog.returnValue);
                    }
                    dialog_xtree["modalDialog"].remove();
                }
            });

            dialog_xtree["modalDialog"].dialogArguments = obj;

            dialog_xtree["hasWincModalDialog"] = true;

            dialog_xtree["closeModalDialogResult"] = function(result){
                if(result){
                    callback(result);
                }
                dialog_xtree["modalDialog"].dialog( "close" );
            };

            var frameDialog = window.frames.modalDialog;
            frameDialog.dialogArguments = obj;
            frameDialog.close=function(){
                dialog_xtree["closeModalDialogResult"](frameDialog.returnValue);
            }
        };
    }

</script>
<script type="text/javascript" src="${ctx}/scripts/validator.jsp"></script>

</body>
</html>